package com.cucn.eduservice.controller.front;

import com.cucn.commonutils.Result;
import com.cucn.eduservice.entity.EduCourse;
import com.cucn.eduservice.entity.EduTeacher;
import com.cucn.eduservice.service.EduCourseService;
import com.cucn.eduservice.service.EduTeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 首页数据显示前端控制器
 *
 * @author KouChaoJie
 * @since: 2021/10/9 10:56
 */
@RestController
//@CrossOrigin
@RequestMapping("/eduservice/indexfront")
public class IndexFrontController {
    @Autowired
    private EduCourseService courseService;
    @Autowired
    private EduTeacherService teacherService;

    /**
     * 查询前8条热门课程,查询前4条名师,首页面显示
     */
    @GetMapping("/index")
    public Result index() {
        List<EduCourse> eduList = courseService.selectCourseList();

        List<EduTeacher> teacherList = teacherService.selectTeacherList();

        return Result.ok().data("eduList", eduList).data("teacherList", teacherList);
    }
}
